package com.hailiao.beidou.message.data.startup

import android.app.Application
import android.content.Context
import androidx.startup.Initializer
import com.hailiao.beidou.message.data.message.MessageReceiver
import com.hailiao.beidou.message.data.setting.LogRepository
import com.tencent.mmkv.MMKV

/**
 * 启动初始化
 * @Author d10ng
 * @Date 2023/9/1 13:51
 */
internal class StartupInitializer : Initializer<Unit> {

    companion object {
        lateinit var application: Application
    }

    override fun create(context: Context) {
        application = context as Application
        // 初始化MMKV
        MMKV.initialize(application)
        // 启动消息接收器
        MessageReceiver.start()
        // 启动日志收集
        LogRepository.start()
    }

    override fun dependencies(): MutableList<Class<out Initializer<*>>> {
        return mutableListOf()
    }
}

internal val ctx by lazy { StartupInitializer.application }